package com.huishu.goods.fegin.fallback;

import com.huishu.commons.pojo.Result;
import com.huishu.goods.fegin.OrderFeignClient;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @ClassName：UserFeignClientFallBack
 * @Author: ljj
 * @Date: 2023/4/10 16:28
 */
@Component
@Slf4j
public class OrderFeignClientFallBack implements FallbackFactory<OrderFeignClient> {

    @Override
    public OrderFeignClient create(Throwable throwable) {
        String msg = throwable == null ? "" : throwable.getMessage();
        if (!StringUtils.isEmpty(msg)) {
            log.error(msg);
        }
        return new OrderFeignClient() {
            @Override
            public Result removeCartltemBySkus(List<String> skus) {
                return Result.fail(msg);
            }

            @Override
            public Result removeCartltemByProductId(Long id) {
                return Result.fail(msg);
            }
        };
    }
}
